#include <assert.h>
#include "scene.h"
#include "ctrlboard.h"
#include "mg_Lcd_Driver.h"
#include "mg_Device.h"
#include "mg_Rs485Protocol.h"
#include "mg_Rotate.h"
/* widgets:
Layer_MainMenu4
Background_Mainmenu4
CoverFlow_Mainmenu4
Container_Config
Text17
PopupButton_Config
Container_MainMenu4_29
Text_MM4_Page29
Text_MM4_State29
Text_MM4_Name2_29
Text_MM4_Name1_29
PopupButton_MainMenu4_29
Container_MainMenu4_28
Text_MM4_Page28
Text_MM4_State28
Text_MM4_Name2_28
Text_MM4_Name1_28
PopupButton_MainMenu4_28
Container_MainMenu4_27
Text_MM4_Page27
Text_MM4_State27
Text_MM4_Name2_27
Text_MM4_Name1_27
PopupButton_MainMenu4_27
Container_MainMenu4_26
Text_MM4_Page26
Text_MM4_State26
Text_MM4_Name2_26
Text_MM4_Name1_26
PopupButton_MainMenu4_26
Container_MainMenu4_25
Text_MM4_Page25
Text_MM4_State25
Text_MM4_Name2_25
Text_MM4_Name1_25
PopupButton_MainMenu4_25
Container_MainMenu4_24
Text_MM4_Page24
Text_MM4_State24
Text_MM4_Name2_24
Text_MM4_Name1_24
PopupButton_MainMenu4_24
Container_MainMenu4_23
Text_MM4_Page23
Text_MM4_State23
Text_MM4_Name2_23
Text_MM4_Name1_23
PopupButton_MainMenu4_23
Container_MainMenu4_22
Text_MM4_Page22
Text_MM4_State22
Text_MM4_Name2_22
Text_MM4_Name1_22
PopupButton_MainMenu4_22
Container_MainMenu4_21
Text_MM4_Page21
Text_MM4_State21
Text_MM4_Name2_21
Text_MM4_Name1_21
PopupButton_MainMenu4_21
Container_MainMenu4_20
Text_MM4_Page20
Text_MM4_State20
Text_MM4_Name2_20
Text_MM4_Name1_20
PopupButton_MainMenu4_20
Container_MainMenu4_19
Text_MM4_Page19
Text_MM4_State19
Text_MM4_Name2_19
Text_MM4_Name1_19
PopupButton_MainMenu4_19
Container_MainMenu4_18
Text_MM4_Page18
Text_MM4_State18
Text_MM4_Name2_18
Text_MM4_Name1_18
PopupButton_MainMenu4_18
Container_MainMenu4_17
Text_MM4_Page17
Text_MM4_State17
Text_MM4_Name2_17
Text_MM4_Name1_17
PopupButton_MainMenu4_17
Container_MainMenu4_16
Text_MM4_Page16
Text_MM4_State16
Text_MM4_Name2_16
Text_MM4_Name1_16
PopupButton_MainMenu4_16
Container_MainMenu4_15
Text_MM4_Page15
Text_MM4_State15
Text_MM4_Name2_15
Text_MM4_Name1_15
PopupButton_MainMenu4_15
Container_MainMenu4_14
Text_MM4_Page14
Text_MM4_State14
Text_MM4_Name2_14
Text_MM4_Name1_14
PopupButton_MainMenu4_14
Container_MainMenu4_13
Text_MM4_Page13
Text_MM4_State13
Text_MM4_Name2_13
Text_MM4_Name1_13
PopupButton_MainMenu4_13
Container_MainMenu4_12
Text_MM4_Page12
Text_MM4_State12
Text_MM4_Name2_12
Text_MM4_Name1_12
PopupButton_MainMenu4_12
Container_MainMenu4_11
Text_MM4_Page11
Text_MM4_State11
Text_MM4_Name2_11
Text_MM4_Name1_11
PopupButton_MainMenu4_11
Container_MainMenu4_10
Text_MM4_Page10
Text_MM4_State10
Text_MM4_Name2_10
Text_MM4_Name1_10
PopupButton_MainMenu4_10
Container_MainMenu4_9
Text_MM4_Page9
Text_MM4_State9
Text_MM4_Name2_9
Text_MM4_Name1_9
PopupButton_MainMenu4_9
Container_MainMenu4_8
Text_MM4_Page8
Text_MM4_State8
Text_MM4_Name2_8
Text_MM4_Name1_8
PopupButton_MainMenu4_8
Container_MainMenu4_7
Text_MM4_Page7
Text_MM4_State7
Text_MM4_Name2_7
Text_MM4_Name1_7
PopupButton_MainMenu4_7
Container_MainMenu4_6
Text_MM4_Page6
Text_MM4_State6
Text_MM4_Name2_6
Text_MM4_Name1_6
PopupButton_MainMenu4_6
Container_MainMenu4_5
Text_MM4_Page5
Text_MM4_State5
Text_MM4_Name2_5
Text_MM4_Name1_5
PopupButton_MainMenu4_5
Container_MainMenu4_4
Text_MM4_Page4
Text_MM4_State4
Text_MM4_Name2_4
Text_MM4_Name1_4
PopupButton_MainMenu4_4
Container_MainMenu4_3
Text_MM4_Page3
Text_MM4_State3
Text_MM4_Name2_3
Text_MM4_Name1_3
PopupButton_MainMenu4_3
Container_MainMenu4_2
Text_MM4_Page2
Text_MM4_State2
Text_MM4_Name2_2
Text_MM4_Name1_2
PopupButton_MainMenu4_2
Container_MainMenu4_1
Text_MM4_Page1
Text_MM4_State1
Text_MM4_Name2_1
Text_MM4_Name1_1
PopupButton_MainMenu4_1
Container_MainMenu4_0
Text_MM4_Page0
Text_MM4_State0
Text_MM4_Name2_0
Text_MM4_Name1_0
PopupButton_MainMenu4_0
*/

static ITUBackground* Background_Mainmenu4;
static ITUCoverFlow* CoverFlow_Mainmenu4;
static ITUContainer* Container_MainMenu4[DeviceNumMax];
static ITUPopupButton* PopupButton_MainMenu4[DeviceNumMax];
static ITUText* Text_MM4_Name1[DeviceNumMax];
static ITUText* Text_MM4_Name2[DeviceNumMax];
static ITUText* Text_MM4_State[DeviceNumMax];
static ITUText* Text_MM4_Page[DeviceNumMax];
static ITUText* Text_MM4_Setting;
static bool Is_HaveDevice = false;
bool MainMenu4OnEnter(ITUWidget* widget, char* param)
{
	uint8_t i, PageNum_D = 0;
	char PageNum[3], Page[10];
	char DeviceState_Text[20];
	char TempName[64], TempNum[64];
	UTF8_TWO_LINE DeviceTempName;
	if (!Background_Mainmenu4)
	{
		Background_Mainmenu4 = ituSceneFindWidget(&theScene, "Background_Mainmenu4");
		assert(Background_Mainmenu4);
		CoverFlow_Mainmenu4 = ituSceneFindWidget(&theScene, "CoverFlow_Mainmenu4");
		assert(CoverFlow_Mainmenu4);
		for (i = 0; i < DeviceNumMax; i++)//加载小部件
		{
			//Container
			strcpy(TempName, "Container_MainMenu4_");
			strcat(TempName, itoa(i, TempNum, 10));
			Container_MainMenu4[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Container_MainMenu4[i]);
			//PopupButton
			strcpy(TempName, "PopupButton_MainMenu4_");
			strcat(TempName, itoa(i, TempNum, 10));
			PopupButton_MainMenu4[i] = ituSceneFindWidget(&theScene, TempName);
			assert(PopupButton_MainMenu4[i]);
			//Text_MM_Name1
			strcpy(TempName, "Text_MM4_Name1_");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM4_Name1[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM4_Name1[i]);
			//Text_MM_Name2
			strcpy(TempName, "Text_MM4_Name2_");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM4_Name2[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM4_Name2[i]);
			//Text_MM_State
			strcpy(TempName, "Text_MM4_State");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM4_State[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM4_State[i]);
			//Text_MM_Page
			strcpy(TempName, "Text_MM4_Page");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM4_Page[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM4_Page[i]);
		}
		Text_MM4_Setting = ituSceneFindWidget(&theScene, "Text_MM4_Setting");
		assert(Text_MM4_Setting);
	}
	ituWidgetSetVisible(CoverFlow_Mainmenu4, false);//设置为显示
	for (i = 1; i <= DeviceNumMax; i++)//获取总页数
	{
		if (TFT_Device[i].DeviceIsAllocation == true)
			PageNum_D++;
	}
	itoa(PageNum_D, PageNum, 10);//将总页数转成字符串
	//对每个按键进行编辑
	Is_HaveDevice = false;
	PageNum_D = 0;//页码归零
	for (i = 1; i <= DeviceNumMax; i++)
	{
		if (Sys.Language == MG_LANGUAGE_CHS)
		{
			Text_MM4_Name1[i - 1]->fontIndex = 5;
			Text_MM4_Name1[i - 1]->boldSize = 1;
			ituTextSetFontSize(Text_MM4_Name1[i - 1], 30);
			ituWidgetSetY(Text_MM4_Name1[i - 1], 84);
			Text_MM4_Name2[i - 1]->fontIndex = 5;
			Text_MM4_Name2[i - 1]->boldSize = 1;
			ituTextSetFontSize(Text_MM4_Name2[i - 1], 30);
			ituWidgetSetY(Text_MM4_Name2[i - 1], 116);
			Text_MM4_State[i - 1]->fontIndex = 1;
			Text_MM4_State[i - 1]->boldSize = 1;
			ituTextSetFontSize(Text_MM4_State[i - 1], 19);
			ituWidgetSetY(Text_MM4_State[i - 1], 46);
			Text_MM4_Page[i - 1]->fontIndex = 1;
			Text_MM4_Page[i - 1]->boldSize = 1;
			ituWidgetSetY(Text_MM4_Page[i - 1], 164);
		}
		else if (Sys.Language == MG_LANGUAGE_ENG)
		{
			Text_MM4_Name1[i - 1]->fontIndex = 4;
			Text_MM4_Name1[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM4_Name1[i - 1], 22);
			ituWidgetSetY(Text_MM4_Name1[i - 1], 88);
			Text_MM4_Name2[i - 1]->fontIndex = 4;
			Text_MM4_Name2[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM4_Name2[i - 1], 22);
			ituWidgetSetY(Text_MM4_Name2[i - 1], 112);
			Text_MM4_State[i - 1]->fontIndex = 7;
			Text_MM4_State[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM4_State[i - 1], 15);
			ituWidgetSetY(Text_MM4_State[i - 1], 50);
			Text_MM4_Page[i - 1]->fontIndex = 7;
			Text_MM4_Page[i - 1]->boldSize = 0;
			ituWidgetSetY(Text_MM4_Page[i - 1], 160);
		}
		else if (Sys.Language == MG_LANGUAGE_ZHTW)
		{
			Text_MM4_Name1[i - 1]->fontIndex = 8;
			Text_MM4_Name1[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM4_Name1[i - 1], 24);
			ituWidgetSetY(Text_MM4_Name1[i - 1], 84);
			Text_MM4_Name2[i - 1]->fontIndex = 8;
			Text_MM4_Name2[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM4_Name2[i - 1], 24);
			ituWidgetSetY(Text_MM4_Name2[i - 1], 116);
			Text_MM4_State[i - 1]->fontIndex = 8;
			Text_MM4_State[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM4_State[i - 1], 12);
			ituWidgetSetY(Text_MM4_State[i - 1], 46);
			Text_MM4_Page[i - 1]->fontIndex = 8;
			Text_MM4_Page[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM4_Page[i - 1], 12);
			ituWidgetSetY(Text_MM4_Page[i - 1], 164);
		}
		
		if (TFT_Device[i].DeviceIsAllocation == true)
		{
			Is_HaveDevice = true;
			PageNum_D++;
			printf("Device No.%d : \n", i);
			//设备是否显示
			ituWidgetSetVisible(Container_MainMenu4[i - 1], true);//设置为显示
			if (TFT_Device[i].DeviceEventType == 1)//设备名称拆解
				DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Device.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Device.DeviceNameLen);//获取合理的换行字符串
			else//场景名称拆解
				DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceNameLen);//获取合理的换行字符串
			ituTextSetString(Text_MM4_Name1[i - 1], DeviceTempName.DeviceName1);
			ituTextSetString(Text_MM4_Name2[i - 1], DeviceTempName.DeviceName2);
			if (strlen(DeviceTempName.DeviceName2) == 0)//单行字母
			{
				if (Sys.Language == MG_LANGUAGE_CHS)
					ituWidgetSetY(Text_MM4_Name1[i - 1], 96);
				else if (Sys.Language == MG_LANGUAGE_ENG)
					ituWidgetSetY(Text_MM4_Name1[i - 1], 100);
			}
			printf("Name : %s\n", TFT_Device[i].TFTSCEQ.TFT_Device.DeviceName);
			//设备状态显示
			GetText_DeviceState(i, DeviceState_Text);
			ituTextSetString(Text_MM4_State[i - 1], DeviceState_Text);
			printf("State : %s\n", DeviceState_Text);
			//页码显示
			itoa(PageNum_D, Page, 10);
			strcat(Page, "/");
			strcat(Page, PageNum);
			ituTextSetString(Text_MM4_Page[i - 1], Page);
			printf("Page : %s\n", Page);
		}
		else
		{
			printf("Device No.%d is not exist! \n", i);
			ituWidgetSetVisible(Container_MainMenu4[i - 1], false);//设置为隐藏
		}
	}
	if (Is_HaveDevice == false)//没有设备
	{
		ituWidgetSetVisible(Container_MainMenu4[0], true);//设置为显示
		ituTextSetString(Text_MM4_State[0], "");
		if (Sys.Language == MG_LANGUAGE_CHS)
		{
			ituTextSetString(Text_MM4_Name1[0], "暂未");
			ituTextSetString(Text_MM4_Name2[0], "配置");
		}
		else if (Sys.Language == MG_LANGUAGE_ENG)
		{
			ituTextSetString(Text_MM4_Name1[0], "Not");
			ituTextSetString(Text_MM4_Name2[0], "configured");
		}
		else if (Sys.Language == MG_LANGUAGE_ZHTW)
		{
			ituTextSetString(Text_MM4_Name1[0], "暫未");
			ituTextSetString(Text_MM4_Name2[0], "配置");
		}
		ituTextSetString(Text_MM4_Page[0], "1/1");
		ituCoverFlowGoto(CoverFlow_Mainmenu4, 0);
	}
	if (Sys.Language == MG_LANGUAGE_CHS)
	{
		Text_MM4_Setting->fontIndex = 5;
		Text_MM4_Setting->boldSize = 1;
		ituTextSetFontSize(Text_MM4_Setting, 25);
		ituWidgetSetY(Text_MM4_Setting, 100);
		ituWidgetSetX(Text_MM4_Setting, 69);
	}
	else if (Sys.Language == MG_LANGUAGE_ENG)
	{
		Text_MM4_Setting->fontIndex = 4;
		Text_MM4_Setting->boldSize = 0;
		ituTextSetFontSize(Text_MM4_Setting, 22);
		ituWidgetSetY(Text_MM4_Setting, 102);
		ituWidgetSetX(Text_MM4_Setting, 67);
	}
	else if (Sys.Language == MG_LANGUAGE_ZHTW)
	{
		Text_MM4_Setting->fontIndex = 8;
		Text_MM4_Setting->boldSize = 0;
		ituTextSetFontSize(Text_MM4_Setting, 24);
		ituWidgetSetY(Text_MM4_Setting, 103);
		ituWidgetSetX(Text_MM4_Setting, 68);
	}
	ituWidgetSetVisible(CoverFlow_Mainmenu4, true);//设置为显示
	ituWidgetSetVisible(Background_Mainmenu4, true);//设置为显示
	Set_Rotate_Block(120);//设置间隔刻度
	return true;
}

bool MainMenu4OnLeave(ITUWidget* widget, char* param)
{
	ituWidgetSetVisible(Background_Mainmenu4, false);//设置为隐藏
    return true;
}

bool MainMenu4OnTimer(ITUWidget* widget, char* param)
{
	static uint8_t TempIndex = 1;
	uint8_t i, PageNum_D = 0;
	char PageNum[3], Page[10];
	char DeviceState_Text[20];
	UTF8_TWO_LINE DeviceTempName;

	//用户操作
	if (Action_Cmd.User_Action == Left_Slide || Action_Cmd.User_Action == Anticlockwise_Rotation)
	{
		if (CoverFlowCheckIdle(CoverFlow_Mainmenu4))
		{
			ituCoverFlowPrev(CoverFlow_Mainmenu4);
		}
		Clear_User_Action();
	}
	else if (Action_Cmd.User_Action == Right_Slide || Action_Cmd.User_Action == Clockwise_Rotation)
	{
		if (CoverFlowCheckIdle(CoverFlow_Mainmenu4))
		{
			ituCoverFlowNext(CoverFlow_Mainmenu4);
		}
		Clear_User_Action();
	}

	//滑动检查，获取当前界面状态
	DisplayValue.TFT_Display_Device = CoverFlow_Mainmenu4->focusIndex + 1;
	if (DisplayValue.TFT_Display_Device != TempIndex)
	{
		MessageFlag[MSG_GET_DEVICE_STATE] = ON;
		MessageFlag[MSG_GET_DEVICE_CONFIG] = ON;
		TempIndex = DisplayValue.TFT_Display_Device;
	}

	//设备具体状态显示
	if (MessageFlag[MSG_GUI_STATE_UPDATE] == ON)
	{
		for (i = 1; i <= DeviceNumMax; i++)
		{
			if (TFT_Device[i].DeviceIsAllocation == true)
			{
				//设备状态显示
				GetText_DeviceState(i, DeviceState_Text);
				ituTextSetString(Text_MM4_State[i - 1], DeviceState_Text);
			}
		}
		MessageFlag[MSG_GUI_STATE_UPDATE] = OFF;
	}
	//设备具体状态显示
	if (MessageFlag[MSG_GUI_CONFIG_UPDATE] == ON)
	{
		ituWidgetSetVisible(CoverFlow_Mainmenu4, false);//设置为隐藏
		PageNum_D = 0;
		for (i = 1; i <= DeviceNumMax; i++)//获取总页数
		{
			if (TFT_Device[i].DeviceIsAllocation == true)
				PageNum_D++;
		}
		itoa(PageNum_D, PageNum, 10);//将总页数转成字符串
		//对每个按键进行编辑
		Is_HaveDevice = false;
		PageNum_D = 0;//页码归零
		for (i = 1; i <= DeviceNumMax; i++)
		{
			if (Sys.Language == MG_LANGUAGE_CHS)
			{
				Text_MM4_Name1[i - 1]->fontIndex = 5;
				Text_MM4_Name1[i - 1]->boldSize = 1;
				ituTextSetFontSize(Text_MM4_Name1[i - 1], 30);
				ituWidgetSetY(Text_MM4_Name1[i - 1], 84);
				Text_MM4_Name2[i - 1]->fontIndex = 5;
				Text_MM4_Name2[i - 1]->boldSize = 1;
				ituTextSetFontSize(Text_MM4_Name2[i - 1], 30);
				ituWidgetSetY(Text_MM4_Name2[i - 1], 116);
				Text_MM4_State[i - 1]->fontIndex = 1;
				Text_MM4_State[i - 1]->boldSize = 1;
				ituTextSetFontSize(Text_MM4_State[i - 1], 19);
				ituWidgetSetY(Text_MM4_State[i - 1], 46);
				Text_MM4_Page[i - 1]->fontIndex = 1;
				Text_MM4_Page[i - 1]->boldSize = 1;
				ituWidgetSetY(Text_MM4_Page[i - 1], 164);
			}
			else if (Sys.Language == MG_LANGUAGE_ENG)
			{
				Text_MM4_Name1[i - 1]->fontIndex = 4;
				Text_MM4_Name1[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM4_Name1[i - 1], 22);
				ituWidgetSetY(Text_MM4_Name1[i - 1], 88);
				Text_MM4_Name2[i - 1]->fontIndex = 4;
				Text_MM4_Name2[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM4_Name2[i - 1], 22);
				ituWidgetSetY(Text_MM4_Name2[i - 1], 112);
				Text_MM4_State[i - 1]->fontIndex = 7;
				Text_MM4_State[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM4_State[i - 1], 15);
				ituWidgetSetY(Text_MM4_State[i - 1], 50);
				Text_MM4_Page[i - 1]->fontIndex = 7;
				Text_MM4_Page[i - 1]->boldSize = 0;
				ituWidgetSetY(Text_MM4_Page[i - 1], 160);
			}
			else if (Sys.Language == MG_LANGUAGE_ZHTW)
			{
				Text_MM4_Name1[i - 1]->fontIndex = 8;
				Text_MM4_Name1[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM4_Name1[i - 1], 24);
				ituWidgetSetY(Text_MM4_Name1[i - 1], 84);
				Text_MM4_Name2[i - 1]->fontIndex = 8;
				Text_MM4_Name2[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM4_Name2[i - 1], 24);
				ituWidgetSetY(Text_MM4_Name2[i - 1], 116);
				Text_MM4_State[i - 1]->fontIndex = 8;
				Text_MM4_State[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM4_State[i - 1], 12);
				ituWidgetSetY(Text_MM4_State[i - 1], 46);
				Text_MM4_Page[i - 1]->fontIndex = 8;
				Text_MM4_Page[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM4_Page[i - 1], 12);
				ituWidgetSetY(Text_MM4_Page[i - 1], 164);
			}
			if (TFT_Device[i].DeviceIsAllocation == true)
			{
				Is_HaveDevice = true;
				PageNum_D++;
				ituWidgetSetVisible(Container_MainMenu4[i - 1], true);//设置为显示
				if (TFT_Device[i].DeviceEventType == 1)//设备名称拆解
					DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Device.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Device.DeviceNameLen);//获取合理的换行字符串
				else//场景名称拆解
					DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceNameLen);//获取合理的换行字符串
				ituTextSetString(Text_MM4_Name1[i - 1], DeviceTempName.DeviceName1);
				ituTextSetString(Text_MM4_Name2[i - 1], DeviceTempName.DeviceName2);
				if (strlen(DeviceTempName.DeviceName2) == 0)//单行字母
				{
					if (Sys.Language == MG_LANGUAGE_CHS)
						ituWidgetSetY(Text_MM4_Name1[i - 1], 96);
					else if (Sys.Language == MG_LANGUAGE_ENG)
						ituWidgetSetY(Text_MM4_Name1[i - 1], 100);
				}
				//设备状态显示
				ituTextSetString(Text_MM4_State[i - 1], "");
				//页码显示
				itoa(PageNum_D, Page, 10);
				strcat(Page, "/");
				strcat(Page, PageNum);
				ituTextSetString(Text_MM4_Page[i - 1], Page);
			}
			else
				ituWidgetSetVisible(Container_MainMenu4[i - 1], false);//设置为隐藏
		}
		if (Is_HaveDevice == false)//没有设备
		{
			ituWidgetSetVisible(Container_MainMenu4[0], true);//设置为显示
			ituTextSetString(Text_MM4_State[0], "");
			if (Sys.Language == MG_LANGUAGE_CHS)
			{
				ituTextSetString(Text_MM4_Name1[0], "暂未");
				ituTextSetString(Text_MM4_Name2[0], "配置");
			}
			else if (Sys.Language == MG_LANGUAGE_ENG)
			{
				ituTextSetString(Text_MM4_Name1[0], "Not");
				ituTextSetString(Text_MM4_Name2[0], "configured");
			}
			else if (Sys.Language == MG_LANGUAGE_ZHTW)
			{
				ituTextSetString(Text_MM4_Name1[0], "暫未");
				ituTextSetString(Text_MM4_Name2[0], "配置");
			}
			ituTextSetString(Text_MM4_Page[0], "1/1");
			ituCoverFlowGoto(CoverFlow_Mainmenu4, 0);
		}
		ituWidgetSetVisible(CoverFlow_Mainmenu4, true);//设置为显示
		MessageFlag[MSG_GUI_CONFIG_UPDATE] = OFF;
	}
	//进入测试模式
	if (MessageFlag[MSG_HARDWARE_TEST] == ON)
	{
		MessageFlag[MSG_HARDWARE_TEST] = OFF;
		ITULayer* Layer_TouchTest = ituSceneFindWidget(&theScene, "Layer_TouchTest");
		assert(Layer_TouchTest);
		ituLayerGoto(Layer_TouchTest);
	}
	//切换彩单类型
	if (MessageFlag[MSG_GUI_SWITCH_MAINMENU] == ON)
	{
		MessageFlag[MSG_GUI_SWITCH_MAINMENU] = OFF;
		GotoMainMenu();
	}
    return true;
}
